package cn.com.inossem.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.com.inossem.systembartint.SystemBarTintManager;

public class DialogActivity extends Activity {

	RelativeLayout rlbut;

	LinearLayout llayout01, llayout02;
	int type;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			setTranslucentStatus(true);
		}

		SystemBarTintManager tintManager = new SystemBarTintManager(this);
		tintManager.setStatusBarTintEnabled(true);
		tintManager.setTintColor(getResources().getColor(R.color.app_main));

		setContentView(R.layout.activity_dialog);

		type = getIntent().getIntExtra("type", 0);

		TextView text1 = (TextView) this.findViewById(R.id.text1);
		TextView text2 = (TextView) this.findViewById(R.id.text2);
		switch (type) {
			case 0:
				break;
			case 1:
				text1.setText("编辑项目");
				text2.setText("清除已失效项目");
				break;
			default:
				break;
		}

		llayout01 = (LinearLayout) this.findViewById(R.id.llayout01);
		llayout01.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (type == 0) {
					setResult(10);
					finish();
				} else if (type == 1) {
					setResult(1);
					finish();
				}
			}
		});

		llayout02 = (LinearLayout) this.findViewById(R.id.llayout02);
		llayout02.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (type == 0) {
					Intent intent = new Intent(DialogActivity.this,
							ListJobsActivity.class);
					startActivity(intent);
					finish();
				} else if (type == 1) {
					setResult(10);
					finish();
				}
			}
		});

		rlbut = (RelativeLayout) this.findViewById(R.id.rlbut);
		rlbut.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				System.out.println("222222222222222222");
				finish();
			}
		});
	}

	private void setTranslucentStatus(boolean on) {
		Window win = getWindow();
		WindowManager.LayoutParams winParams = win.getAttributes();
		final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
		if (on) {
			winParams.flags |= bits;
		} else {
			winParams.flags &= ~bits;
		}
		win.setAttributes(winParams);
	}
}
